//
//  DataLocalManager.m
//  objective_c_language
//
//  Created by 王玉龙 on 2018/6/1.
//  Copyright © 2018年 longlong. All rights reserved.
//

#define kAccount @"account"
#define kPassword @"password"
#define kCookie @"cookie"

#import "DataLocalManager.h"

@implementation DataLocalManager

+ (void)storeAccount:(NSString *)account Password:(NSString *)password
{
    [[NSUserDefaults standardUserDefaults] setObject:account forKey:kAccount];
    [[NSUserDefaults standardUserDefaults] setObject:password forKey:kPassword];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (NSString *)readAccount
{
    return [[NSUserDefaults standardUserDefaults] objectForKey:kAccount];
}

+ (NSString *)readPassword
{
    return [[NSUserDefaults standardUserDefaults] objectForKey:kPassword];
}

+ (void)storeCookie:(NSString *)cookie
{
    if (cookie)
    {
        [[NSUserDefaults standardUserDefaults] setObject:cookie forKey:kCookie];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}

+ (NSString *)readCookie
{
    NSString *cookie = [[NSUserDefaults standardUserDefaults] objectForKey:kCookie];
    if (cookie)
    {
        return cookie;
    }
    return @"";
}

+ (void)logoutAccount
{
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:kAccount];
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:kPassword];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

@end
